# -*- coding: UTF-8 -*-
import random
import time

cardtype=("红桃   ","方块   ","黑桃   ","梅花   ")
cardnum=("A","2","3","4","5","6","7","8","9","10","J","Q","K")

def generatecards():
    cardpairs = []
    for type in cardtype:
        for num in cardnum:
            cardpairs.append((type,num))

    cardpairs.append(("大","王"))
    cardpairs.append(("小","王"))

    return cardpairs

def dispatchards(cardpairs):
    random.shuffle(cardpairs)
    random.shuffle(cardpairs)
    player1cards = []
    player2cards = []
    player3cards = []
    covercardsnum = 3
    for index in range(0,len(cardpairs) - covercardsnum):
        cardpair = cardpairs[index]
        if index%3 == 0:
            player1cards.append(cardpair)
            print()
        elif index %3 == 1:
            player2cards.append(cardpair)
        else:
            player3cards.append(cardpair)
        print(''.join(cardpair),'\t\t',)
        time.sleep(0.1)
    print('\n')

    print(u'玩家1手牌：',len(player1cards))
    for cardpair in player1cards:
        print(''.join(cardpair))
    print()

    print(u'玩家2手牌：', len(player2cards))
    for cardpair in player2cards:
        print(''.join(cardpair))
    print()

    print(u'玩家3手牌：', len(player3cards))
    for cardpair in player3cards:
        print(''.join(cardpair))
    print()

    print(u'底牌：')
    rest_cards=cardpairs[-3:]
    for card in rest_cards:
        print(''.join(card))




if __name__ == '__main__':
    # 生成牌
    cardpairs = generatecards()
    # 分配牌
    dispatchards(cardpairs)